/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.comfacauca.xmlc2.entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author eorozco
 */
@Entity
@Table(name = "requerimiento")
@NamedQueries({
    @NamedQuery(name = "Requerimiento.findAll", query = "SELECT r FROM Requerimiento r"),
    @NamedQuery(name = "Requerimiento.findById", query = "SELECT r FROM Requerimiento r WHERE r.id = :id"),
    @NamedQuery(name = "Requerimiento.findByCodigo", query = "SELECT r FROM Requerimiento r WHERE r.codigo = :codigo"),
    @NamedQuery(name = "Requerimiento.findByTitulo", query = "SELECT r FROM Requerimiento r WHERE r.titulo = :titulo"),
    @NamedQuery(name = "Requerimiento.findByInicio", query = "SELECT r FROM Requerimiento r WHERE r.inicio = :inicio"),
    @NamedQuery(name = "Requerimiento.findByFin", query = "SELECT r FROM Requerimiento r WHERE r.fin = :fin")})
public class Requerimiento implements Serializable {
    @JoinColumn(name = "id_etapa", referencedColumnName = "id")
    @ManyToOne
    private Etapa idEtapa;
    @Column(name = "id_glpi")
    private Integer idGlpi;
    @OneToMany(mappedBy = "idAutor")
    private Collection<Acciones> accionesCollection;
    @OneToMany(mappedBy = "idRequerimiento")
    private Collection<Avance> avanceCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idRequerimiento")
    private Collection<Comentario> comentarioCollection;
    @OneToMany(mappedBy = "idRequerimiento")
    private Collection<Requerimiento> requerimientoCollection;
    @JoinColumn(name = "id_requerimiento", referencedColumnName = "id")
    @ManyToOne
    private Requerimiento idRequerimiento;
    @JoinColumn(name = "id_autor", referencedColumnName = "id")
    @ManyToOne
    private Responsable idAutor;
    @JoinColumn(name = "id_prioridad", referencedColumnName = "id")
    @ManyToOne
    private Prioridad idPrioridad;
  
    @JoinColumn(name = "id_tipo", referencedColumnName = "id")
    @ManyToOne
    private Tiporequerimiento idTipo;
    @OneToMany(mappedBy = "idRequerimiento")
    private Collection<Documento> documentoCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "codigo")
    private String codigo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "titulo")
    private String titulo;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "descripcion")
    private String descripcion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "inicio")
    @Temporal(TemporalType.DATE)
    private Date inicio;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fin")
    @Temporal(TemporalType.DATE)
    private Date fin;
    @JoinColumn(name = "id_responsable", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Responsable idResponsable;
   
    @JoinColumn(name = "id_estado", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Estado idEstado;

    @JoinColumn(name = "id_iteracion", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Iteracion idIteracion;
    
    public Requerimiento() {
    }

    public Requerimiento(Integer id) {
        this.id = id;
    }

    public Requerimiento(Integer id, String codigo, String titulo, String descripcion, Date inicio, Date fin) {
        this.id = id;
        this.codigo = codigo;
        this.titulo = titulo;
        this.descripcion = descripcion;
        this.inicio = inicio;
        this.fin = fin;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Date getInicio() {
        return inicio;
    }

    public void setInicio(Date inicio) {
        this.inicio = inicio;
    }

    public Date getFin() {
        return fin;
    }

    public void setFin(Date fin) {
        this.fin = fin;
    }

    public Responsable getIdResponsable() {
        return idResponsable;
    }

    public void setIdResponsable(Responsable idResponsable) {
        this.idResponsable = idResponsable;
    }

    public Estado getIdEstado() {
        return idEstado;
    }

    public void setIdEstado(Estado idEstado) {
        this.idEstado = idEstado;
    }

    public Iteracion getIdIteracion() {
        return idIteracion;
    }

    public void setIdIteracion(Iteracion idIteracion) {
        this.idIteracion = idIteracion;
    }
    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Requerimiento)) {
            return false;
        }
        Requerimiento other = (Requerimiento) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.comfacauca.xmlc2.entidades.Requerimiento[ id=" + id + " ]";
    }



    public Collection<Documento> getDocumentoCollection() {
        return documentoCollection;
    }

    public void setDocumentoCollection(Collection<Documento> documentoCollection) {
        this.documentoCollection = documentoCollection;
    }

    public Tiporequerimiento getIdTipo() {
        return idTipo;
    }

    public void setIdTipo(Tiporequerimiento idTipo) {
        this.idTipo = idTipo;
    }

    public Prioridad getIdPrioridad() {
        return idPrioridad;
    }

    public void setIdPrioridad(Prioridad idPrioridad) {
        this.idPrioridad = idPrioridad;
    }

    public Responsable getIdAutor() {
        return idAutor;
    }

    public void setIdAutor(Responsable idAutor) {
        this.idAutor = idAutor;
    }

    public Collection<Requerimiento> getRequerimientoCollection() {
        return requerimientoCollection;
    }

    public void setRequerimientoCollection(Collection<Requerimiento> requerimientoCollection) {
        this.requerimientoCollection = requerimientoCollection;
    }

    public Requerimiento getIdRequerimiento() {
        return idRequerimiento;
    }

    public void setIdRequerimiento(Requerimiento idRequerimiento) {
        this.idRequerimiento = idRequerimiento;
    }

    public Collection<Comentario> getComentarioCollection() {
        return comentarioCollection;
    }

    public void setComentarioCollection(Collection<Comentario> comentarioCollection) {
        this.comentarioCollection = comentarioCollection;
    }

    public Collection<Avance> getAvanceCollection() {
        return avanceCollection;
    }

    public void setAvanceCollection(Collection<Avance> avanceCollection) {
        this.avanceCollection = avanceCollection;
    }

    public Collection<Acciones> getAccionesCollection() {
        return accionesCollection;
    }

    public void setAccionesCollection(Collection<Acciones> accionesCollection) {
        this.accionesCollection = accionesCollection;
    }

    public Integer getIdGlpi() {
        return idGlpi;
    }

    public void setIdGlpi(Integer idGlpi) {
        this.idGlpi = idGlpi;
    }    

    public Etapa getIdEtapa() {
        return idEtapa;
    }

    public void setIdEtapa(Etapa idEtapa) {
        this.idEtapa = idEtapa;
    }
}